<template>
  <!-- 工单处理 -->
  <alarmevents :title="title" :data="alarmList" :isshowlefts="isshowlefts"/>
</template>
<script lang="ts" setup>
import {screenworkorder} from '@/api/screen/largeData'
import alarmevents from '@/views/large-data-screen/component/public/alarmevents.vue'
import img2 from '@/assets/screenimg/samllIcon1.png'
import img3 from '@/assets/screenimg/samllIcon3.png'

import {showWorkOrder} from '@/views/large-data-screen/utils/index'
import { emitter } from '@/utils/mitt'

const isshowlefts = ref(true) //动画效果


const title = ref('工单处理')


const alarmList = ref([
  {
    name: '已处理(起)',
    color: '#21CC31',
    number: 0,
    type: 1,
    img: img2,
    clickFun: () => showWorkOrder({defaultSearch: {workOrderStatus: 4}})
  },

  {
    name: '待处理(起)',
    number: 0,
    color: '#FF802B',
    type: 3,
    img: img3,
    clickFun: () => showWorkOrder({defaultSearch: {workOrderStatus: 1}})
  },

])
const re = (data) => {
  getscreeninspect()
}
onMounted(() => {
  getscreeninspect()
  emitter.on('alarmEvents',re)
})

onBeforeUnmount(() => {
    emitter.off('alarmEvents',re)
})
//获取巡检
const getscreeninspect = () => {
  screenworkorder({
    workOrderDT: 0,//工单处理日期类型 （0-全部 1 日 2周 3 月 4 年）
    workOrderTypeDT: 0 //工单类型统计日期类型  （0-全部   3 月 5 上月）

  }).then(res => {

    alarmList.value[0].number = res.result.workOrder.workOrderDealed
    alarmList.value[1].number = res.result.workOrder.workOrderWait


  })
}


</script>
